﻿
@if (ShowDialog)
{
    <div class="modal fade show d-block" id="exampleModal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-xl" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="titleLabel">Audit Logs</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close" @onclick="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">

                    @if (AuditLogs == null)
                    {
                        <p><em>Loading...</em></p>
                    }
                    else
                    {
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>Date Time</th>
                                    <th>User Name</th>
                                    <th>Action</th>
                                    <th>Code</th>
                                    <th>Name</th>
                                    <th>Description</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach (var log in AuditLogs)
                                {
                                    <tr>
                                        <td>@log.CreatedDateTime.</td>
                                        <td>@log.UserName</td>
                                        <td>@log.Action</td>
                                        <td style="color:@(log.HighLight["code"] ? "red" : "")">
                                            @log.Data.Code
                                        </td>
                                        <td style="color:@(log.HighLight["name"] ? "red" : "")">
                                            @log.Data.Name
                                        </td>
                                        <td style="color:@(log.HighLight["description"] ? "red" : "")">
                                            @log.Data.Description
                                        </td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                    }

                </div>
            </div>
        </div>
    </div>
}